package com.huawei;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Description: HJ102 字符统计
 *
 * @author weiruibai.vendor
 * Date: 2022/9/2 11:04
 */
public class JH102 {

    /**
     * aaddccdc
     *
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] str = br.readLine().toCharArray();
        Map<Character, Obj> map = new HashMap<>();

        List<Obj> list = new ArrayList<>();
        for (int i = 0; i < str.length; i++) {
            char ch = str[i];
            Obj obj;
            if (map.containsKey(ch)) {
                obj = map.get(ch);
                list.remove(obj);
                obj.count++;
            } else {
                obj = new Obj(1);
                obj.ch = ch;
            }
            map.put(ch, obj);
            list.add(obj);
        }
        list.sort(new Comparator<Obj>() {
            @Override
            public int compare(Obj o1, Obj o2) {
                return o1.count == o2.count ? o1.ch - o2.ch : o2.count - o1.count;
            }
        });
        for (Obj ch : list) {
            System.out.print(ch.ch);
        }
    }

    private static class Obj {
        public Character ch;
        public int count;

        public Obj(int count) {
            this.count = count;
        }

        public String toString() {
            return "Obj:{ch:" + ch + ",count:" + count + "}";
        }
    }
}
